package oo.shootgame;
import java.awt.image.BufferedImage;
/** 狗熊机*/
public class Hero extends Plane{
	protected int doublefire;
	private BufferedImage[] images={};
	protected int index;
	protected int boom;
	public Hero(){
		image=ShootGame.hero0;
		width=image.getWidth()-20;
		height=image.getHeight()-20;
		boom=2;
		x=200;
		y=350;
		life=50;
		doublefire=0;
		index=0;
		images=new BufferedImage[]{ShootGame.hero0,ShootGame.hero1};
	}
	public void step(){
		index++;
		if(index%50==0){
			image=images[0];
		}
	}
	public Bullet[] shoot(){
		if(doublefire>0){
			doublefire-=3;
			Bullet[] bbt=new Bullet[3];
			bbt[0]=new Bullet(x+width/4,y-10);
			bbt[1]=new Bullet(x+width/2,y-10);
			bbt[2]=new Bullet(x+3*width/4,y-10);			
			return bbt;
		}else{
			Bullet[] bbt=new Bullet[1];
			bbt[0]=new Bullet(x+width/2,y-20);
			return bbt;
		}		
	}
	public void moveto(int x,int y){
		this.x=x-width/2;
		this.y=y-height/2;
	}
	public void addDoubleFire(){
		doublefire+=100;
	}
	public void addlife(){
		life++;
	}
	public boolean hitby(Plane fly){
		if((x-fly.width)<fly.x && fly.x<width+x && fly.y>(y-fly.height) && fly.y<(height+y)){
			image=images[1];
			return true;
		}else{			
			return false;
		}
			
	}
	public void lifedown(){
		life--;
	}
	public void setDoublefire(){
		doublefire=0;
	}
	public Boom boom(){
		return new Boom(x+width/2,y-10);
	}
	
}
